<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.w3.org/1999/xhtml">
<head>
    <title>元数据同步系统</title>
    <link rel="stylesheet" th:href="@{/css/index.css}">
    <link rel="stylesheet" th:href="@{/css/main.css}">
</head>
<body>

<div id="app">

    <div style="padding:10px 20px;">

        <div>
            <h2 style="display: inline-block">元数据同步系统</h2>
            <a href="/v" style="color:#ff4d4d">更新记录</a>
        </div>

        <div style="width:300px;margin:10px 0;">
            <el-input placeholder="系统名称" v-model="searchName" @keyup.enter.native="loadData"></el-input>
        </div>

        <el-table ref="multipleTable" style="width: 100%" :data="pageModel.list" v-loading="dataloading">
            <el-table-column label="部门名称">
                <template slot-scope="scope">{{scope.row.deptName}}</template>
            </el-table-column>
            <el-table-column label="主干业务名称">
                <template slot-scope="scope">{{scope.row.mainBusiness}}</template>
            </el-table-column>
            <el-table-column label="子业务名称">
                <template slot-scope="scope">{{scope.row.childBusiness}}</template>
            </el-table-column>
            <el-table-column label="系统名称">
                <template slot-scope="scope">{{scope.row.sysName}}</template>
            </el-table-column>
            <!--<el-table-column  label="安全等级">-->
            <!--<template slot-scope="scope">{{scope.row.model.securityLevel}}</template>-->
            <!--</el-table-column>-->
            <el-table-column label="系统编码">
                <template slot-scope="scope">{{scope.row.sysCode}}</template>
            </el-table-column>
            <el-table-column label="一级主题分类">
                <template slot-scope="scope">{{scope.row.theme1}}</template>
            </el-table-column>
            <el-table-column label="二级主题分类">
                <template slot-scope="scope">{{scope.row.theme2}}</template>
            </el-table-column>
            <el-table-column label="三级主题分类">
                <template slot-scope="scope">{{scope.row.theme3}}</template>
            </el-table-column>
            <el-table-column label="一级行业分类">
                <template slot-scope="scope">{{scope.row.industry1}}</template>
            </el-table-column>
            <el-table-column label="二级行业分类">
                <template slot-scope="scope">{{scope.row.industry2}}</template>
            </el-table-column>
            <el-table-column label="三级行业分类">
                <template slot-scope="scope">{{scope.row.industry3}}</template>
            </el-table-column>

            <el-table-column label="操作" width="300px" fixed="right">
                <template slot-scope="scope">
<!--                    <a target="_blank" :href='"set/check?sysCode=" + scope.row.sysCode' style="color:blue">验证</a>-->
                    <!--                <a target="_blank" :href='"set/go?sysCode=" + scope.row.sysCode' style="color:blue">同步</a>-->
<!--                    <a target="_blank" :href='"set/goDetail?sysCode=" + scope.row.sysCode' style="color:blue">同步</a>-->
<!--                    <a target="_blank" :href='"set/cleanByCode?sysCode=" + scope.row.sysCode' style="color:blue">清除</a>-->
                    <br/>
                    <a target="_blank" :href='"/smartWord/go?code=" + scope.row.sysCode' style="color:blue">生成智能提示词</a>
                    <!--                <a target="_blank" href='/jobDetail?jobkey=smartword' style="color:blue">智能提示词监控</a>-->

                    <a target="_blank" :href='"table?sysCode=" + scope.row.sysCode' style="color:blue">查看表信息</a>
                    <br />
                    <a target="_blank" :href='"relation/goDetail?sysCode=" + scope.row.sysCode' style="color:blue">同步关联数据</a>
                    <!--                <a target="_blank" :href='"set/bindCategory?sysCode=" + scope.row.sysCode' style="color:blue">绑定分类</a>-->
                    <br/>
                    <!--                <a target="_blank" :href='"set/buildEnumDomain?sysCode=" + scope.row.sysCode' style="color:blue">补充枚举到图谱</a>-->
                    <!--                <a target="_blank" :href='"set/buildAutoInterpretation?sysCode=" + scope.row.sysCode' style="color:blue">补充自动解读规则</a>-->
                    <!--                <br />-->
                    <a target="_blank" @click="gw_loadTableAndFileMeta(scope.row.sysCode)" style="color:blue">国网-获取表和字段元数据</a>
                    <br/>
                    <a target="_blank" @click="gw_loadTableMeta(scope.row.sysCode)" style="color:blue">国网-获取表元数据</a>
                    <br />
                    <a target="_blank" @click="gw_loadRelationMeta()" style="color:blue">国网-获取关联元数据</a>
                </template>
            </el-table-column>
        </el-table>

        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :page-sizes="[10]"
                       :current-page="pageModel.currentPage" :page-size="pageModel.pageSize"
                       layout="total,prev, pager, next, jumper"
                       :total="pageModel.totalCount"></el-pagination>
    </div>
</div>
</body>

<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/iconfont.js}"></script>
<script th:src="@{/js/vue.js}"></script>
<script th:src="@{/js/index.js}"></script>

<script>
    var contextRoot = "/";
    var loadData = function () {

        var _this = this
        _this.dataloading = true;
        $.ajax({
            type: "get",
            url: contextRoot + "system/GetList",
            data: {currentPage: app.currentPage, name: app.searchName},
            async: true,
            success: function (result) {
                console.log(result);
                if (result.code == 200) {
                    app.pageModel = result.data;
                } else {
                    alert(result.msg);
                }
                _this.dataloading = false;
            },
            error: function () {
                alert("信息获取失败");
            }
        });
    };

    var app = new Vue({
        el: '#app',
        data: {
            searchName: '',
            currentPage: 1,
            pageModel: [],
            name: 'test',
            dataloading: false,
        },
        methods: {
            loadData: loadData,
            handleSizeChange(val) {

            },
            handleCurrentChange(val) {
                app.currentPage = val;
                app.loadData();
            },
            gw_loadTableAndFileMeta(sysCode) {
                console.log(sysCode)
                var r = confirm("确认获取[表和字段]元数据吗");
                if (r == true) {
                    $.ajax({
                        type: "get",
                        url: contextRoot + "meta/loadTableAndFieldMeta",
                        data: {sysCode: sysCode},
                        async: true,
                        success: function (result) {
                            console.log(result)
                            if (result == "ok") {
                                alert("处理成功");
                            } else {
                                alert("处理失败");
                            }
                        },
                        error: function () {
                            alert("信息获取失败");
                        }
                    });
                } else {
                    //alert("已取消操作");
                }
            },
            gw_loadTableMeta(sysCode) {
                console.log(sysCode)
                var r = confirm("确认获取[表]元数据吗");
                if (r == true) {
                    $.ajax({
                        type: "get",
                        url: contextRoot + "meta/loadTableMeta",
                        data: {sysCode: sysCode},
                        async: true,
                        success: function (result) {
                            console.log(result)
                            if (result == "ok") {
                                alert("处理成功");
                            } else {
                                alert("处理失败");
                            }
                        },
                        error: function () {
                            alert("信息获取失败");
                        }
                    });
                } else {
                    //alert("已取消操作");
                }
            },
            gw_loadRelationMeta() {
                var r = confirm("确认获取[关联]元数据吗");
                if (r == true) {
                    $.ajax({
                        type: "get",
                        url: contextRoot + "meta/loadRelationMeta",
                        data: {},
                        async: true,
                        success: function (result) {
                            if (result == "ok") {
                                alert("处理成功");
                            } else {
                                alert("处理失败");
                            }
                        },
                        error: function () {
                            alert("信息获取失败");
                        }
                    });
                } else {
                    //alert("已取消操作");
                }
            }
        }
    })

    app.loadData();
</script>

</html>